package com.jf.yytgd.listener;

import com.jf.yytgd.utils.FileUtil;
import com.jf.yytgd.utils.SqlUtil;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA
 * Description: 工具监听器, 用于调用基于ApplicationContext的工具初始化方法
 * User:22954
 * Date:2025-01-12
 * Time:19:41
 */
@Component
public class UtilsInitializer implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if (event.getApplicationContext().getParent() == null) {
            SqlUtil.init(event.getApplicationContext());
            FileUtil.init(event.getApplicationContext());
        }
    }
}
